<?php

class Model_Track
{

    private $_student = null;

    private $_taskList = array();

    public function __construct(Model_Studnet $student, array $tasks = null)
    {
        $this->_student = $student;
        $this->_taskList = $tasks;
    }


    static public function build(Model_Studnet $student)
    {
        $db = Zend_Db_Table::getDefaultAdapter();
        $select = $db->select();
        /*$select->from('task_assign')
            ->where('studentId = ?', $student->getId());
        */
        $q = 'select * from task where id in '
           . '(select id from task_assign where studentId = '
           . $student->getId() . ') order by dateStart, dateEnd';
        $query = $db->query($q);
        while ($row = $query->fetch()) {
            $task = Model_Task::findById($row['taskId']);
            $tasks[] = $task;
        }

        $list = new self($student, $tasks);

    }

    public function trackData()
    {
        return $this->_taskList
    }
}